<template>
	<view >
		<uni-popup ref="popup"  type="center"  @change="popChange">
			<view class="tip-view">
				<text class="title">请填写签名</text>
				<textarea class="input" @input="onKeyInput" :value="dataSource"/>
				<view class="btn-view">
					<text class="btn-left" @click="leftClick">取消</text>
					<text class="btn-right" @click="rightClick">确定</text>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		name: "input-desc",
		props: {
			isShow:false,
			dataSource:String,
		},
		watch: {
			isShow(val) {
				if(val){
					this.$refs.popup.open();
				}
			}
		},
		data() {
			return {
				inputKey:"",
			};
		},
		methods:{
			onKeyInput: function(event) {
				this.inputKey = event.target.value
			},
			popChange(e) {
				if(!e.show){
					var obj = {
						inputStr: "",
						isclose: false,
						tag:"cancle"
					};
					this.$emit('returnInputDesc', obj);
				}
			},
			leftClick(){
				var obj = {
					inputStr: "",
					isclose: false,
					tag:"cancle"
				};
				this.$emit('returnInputDesc', obj);
				this.$refs.popup.close();
			},
			rightClick(){
				var obj = {
					inputStr: this.inputKey,
					isclose: false,
					tag:"sure"
				};
				this.$emit('returnInputDesc', obj);
				this.$refs.popup.close();
			}
		}
	}
</script>

<style>
	@import "input-desc.css";
</style>
